import 'wiki_config.dart';

/// Wiki搜索结果模型
class WikiSearchResult {
  final WikiItem wiki;
  final double relevance;
  final List<String> matchedFields;

  WikiSearchResult({
    required this.wiki,
    required this.relevance,
    required this.matchedFields,
  });

  factory WikiSearchResult.fromJson(Map<String, dynamic> json) {
    return WikiSearchResult(
      wiki: WikiItem.fromJson(json['wiki']),
      relevance: (json['relevance'] ?? 0.0).toDouble(),
      matchedFields: List<String>.from(json['matchedFields'] ?? []),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'wiki': wiki.toJson(),
      'relevance': relevance,
      'matchedFields': matchedFields,
    };
  }

  @override
  String toString() {
    return 'WikiSearchResult(wiki: ${wiki.name}, relevance: $relevance, matchedFields: $matchedFields)';
  }
}